﻿using System.Drawing;
using System.IO;
using Tsanie.ShellExt.Definitions;

namespace Tsanie.ShellExt.Thumbnail
{
    public class TextProvider : ThumbnailBaseProvider
    {
        public override string ProviderName { get { return "Thumbnail.Text"; } }
        public override string[] Exts { get { return new[] { ".txt" }; } }
        public override ProviderType Type { get { return ProviderType.Thumbnail; } }
        public override string Creator { get { return "Tsanie"; } }
        public override ThumbnailFlags Flags { get { return ThumbnailFlags.Async; } }

        public override Bitmap GetBitmap(string filename, ThumbnailFlags flags, int colorDepth, Size size)
        {
            Bitmap bmp = new Bitmap(256, 256);
            using (StreamReader reader = new StreamReader(filename))
            {
                Graphics g = Graphics.FromImage(bmp);
                g.Clear(Color.White);
                g.DrawString(reader.ReadLine(), SystemFonts.DefaultFont, Brushes.Black, new RectangleF(10, 10, 236, 236));
                reader.Close();
            }
            return bmp;
        }
    }
}
